<?php

Yii::import('application.models._base.BasePageContent');

class PageContent extends BasePageContent {

    public static function model($className = __CLASS__) {
        return parent::model($className);
    }

    public static function label($n = 1) {
        return Yii::t('app', 'Cms Content|Cms Contents', $n);
    }

    public function rules() {
        return array(
            array('page_title, page_content, page_type_id', 'required'),
            array('page_type_id', 'numerical', 'integerOnly' => true),
            array('page_title, meta_tag, photo_name', 'length', 'max' => 145),
            //array('photo_name', 'default', 'setOnEmpty' => true, 'value' => null),
            array('photo_name', 'file', 'types' => 'jpg, jpeg, pdf, gif, png', 'allowEmpty' => true),
            array('id, page_title, page_content, meta_tag, meta_description, photo_name, page_type_id', 'safe', 'on' => 'search'),
        );
    }
    
      public function relations() {
        return array(
            'pageType' => array(self::BELONGS_TO, 'PageType', 'page_type_id')
        );
    }

    public static function getSingleAttributesContent($pageType, $contentId){
        $content = PageContent::model()->findByAttributes(array('page_type_id' => $pageType, 'id' => $contentId));
        return $content;
    }
    public static function getmultiAttributesContent($pageType) {
        $content = PageContent::model()->findAllByAttributes(array('page_type_id' => $pageType));
        return $content;
    }

}
